package tp.pr3.instructions;

import tp.pr3.NavigationModule;
import tp.pr3.instructions.exceptions.InstructionExecutionException;
import tp.pr3.instructions.exceptions.WrongInstructionFormatException;
import tp.pr3.items.ItemContainer;
import tp.pr3.RobotEngine;

public class QuitInstruction
extends java.lang.Object
implements Instruction {
	
	private RobotEngine engine;
	
	public QuitInstruction()
    	{
		 engine = null;
    	}
	
	public Instruction parse(java.lang.String cad) throws WrongInstructionFormatException
	{
		String[] quitString = cad.split(" ");
		if (quitString.length != 1) throw new WrongInstructionFormatException();
		else
		{
			if (cad.equalsIgnoreCase("QUIT") || cad.equalsIgnoreCase("SALIR"))
				return new QuitInstruction();
			else throw new WrongInstructionFormatException();
		}
	}
	
	public void execute() throws InstructionExecutionException
	{
		engine.requestQuit();
	}
	
	public java.lang.String getHelp()
	{
		return ("QUIT | SALIR");
	}
	
	public void configureContext(RobotEngine engine,
            NavigationModule navigation,
            ItemContainer robotContainer)
	{
		this.engine=engine;

	}
            

}
